#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<stdlib.h>

void create_size_file(char *file_name,int size){
    
    int fd;
    if((fd = open(file_name,O_RDWR|O_CREAT|O_TRUNC,0666)) < 0){
        
        perror("创建文件失败");
        return;
    }
    
   int current = lseek(fd,size - 1,SEEK_SET);
    
   if(current == -1 ){
    
       perror("游标移动失败");
       goto end;
   }
    
   char a[]="";
   int w_num;
   if((w_num =  write(fd,a,sizeof(a))) < 0){
    
      perror("写入错误"); 
      goto end;
   }
     



end:close(fd);
    
}

int main(int argc, char *argv[]){
    
    if(argc != 3){
        
        printf("输入格式错误!");   
        return 0;
    }
    
    int size = atoi(argv[2]);

    create_size_file(argv[1],size);
    return 0;
}
